const isNullOrEmpty = function(val) {
  if (val == null || val == "" || typeof(val) == undefined) {
    return true;
  } else {
    return false;
  }
}

// 判断申报状态
const ques_type = (value) => {
  switch(true){
    case value == 1 :
      return '判断';
      break;
    case value == 2 :
      return '多选';
      break;
    case value == 3 :
      return '填空';
      break;
    case value == 4 :
      return '单选';
      break;
  }
};

// 转换时间戳
const timeFormat = (value, format) => {
  let date = new Date(value * 1000);
  let y = date.getFullYear();
  let m = date.getMonth() + 1;
  let d = date.getDate();
  let h = date.getHours();
  let min = date.getMinutes();
  let s = date.getSeconds();
  let result = "";
  if (format == undefined) {
    result = `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d} ${
      h < 10 ? "0" + h : h
      }:${min < 10 ? "0" + min : min}:${s < 10 ? "0" + s : s}`;
  }
  if (format == "yyyy-mm-dd") {
    result = `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}`;
  }
  if (format == "yyyy-mm") {
    result = `${y}-${m < 10 ? "0" + m : m}`;
  }
  if (format == "mm-dd") {
    result = ` ${mm < 10 ? "0" + mm : mm}:${ddmin < 10 ? "0" + dd : dd}`;
  }
  if (format == "hh:mm") {
    result = ` ${h < 10 ? "0" + h : h}:${min < 10 ? "0" + min : min}`;
  }
  if (format == "yyyy") {
    result = `${y}`;
  }
  return result;
};


export {
  isNullOrEmpty,
  ques_type,
  timeFormat
}
